package laba_jdbc;

import java.sql.Date;
import java.util.Objects;

/**
 *
 * @author yakimovich
 */
public class User {

	private long id;
	private String login;
	private String password;
	private String email;
	private String firstName;
	private String lastName;
	private Date birthday;
	private Role role;

	/**
	 * Create User by default
	 */
	public User() {
	}

	/**
	 * Create User with the specified parameters.
	 *
	 * @param id
	 * @param login
	 * @param password
	 * @param email
	 * @param firstName
	 * @param lastName
	 * @param birthday
	 * @param role
	 */
	public User(long id, String login, String password, 
			String email, String firstName, String lastName, 
			Date birthday, Role role) {

		this.id = id;
		this.login = login;
		this.password = password;
		this.email = email;
		this.firstName = firstName;
		this.lastName = lastName;
		this.birthday = birthday;
		this.role = role;
	}

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the login
	 */
	public String getLogin() {
		return login;
	}

	/**
	 * @param login
	 *            the login to set
	 */
	public void setLogin(String login) {
		this.login = login;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the firstName
	 */
	public String getFirstName() {
		return firstName;
	}

	/**
	 * @param firstName
	 *            the firstName to set
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	/**
	 * @return the lastName
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * @param lastName
	 *            the lastName to set
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	/**
	 * @return the birthday
	 */
	public Date getBirthday() {
		return birthday;
	}

	/**
	 * @param birthday
	 *            the birthday to set
	 */
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	/**
     *
     */
	public void newOperation() {
	}

	/**
	 * 
	 * @return
	 */
	public Role getRole() {
		return role;
	}

	/**
	 * 
	 * @param role
	 */
	public void setRole(Role role) {
		this.role = role;
	}

	@Override
	public int hashCode() {
		int hash = 7;
		hash = 53 * hash + (int) (this.id ^ (this.id >>> 32));
		hash = 53 * hash + Objects.hashCode(this.login);
		hash = 53 * hash + Objects.hashCode(this.password);
		hash = 53 * hash + Objects.hashCode(this.email);
		hash = 53 * hash + Objects.hashCode(this.firstName);
		hash = 53 * hash + Objects.hashCode(this.lastName);
		hash = 53 * hash + Objects.hashCode(this.birthday);
		return hash;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final User other = (User) obj;
		if (this.id != other.id) {
			return false;
		}
		if (!Objects.equals(this.login, other.login)) {
			return false;
		}
		if (!Objects.equals(this.password, other.password)) {
			return false;
		}
		if (!Objects.equals(this.email, other.email)) {
			return false;
		}
		if (!Objects.equals(this.firstName, other.firstName)) {
			return false;
		}
		if (!Objects.equals(this.lastName, other.lastName)) {
			return false;
		}
		if (!Objects.equals(this.birthday, other.birthday)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "User{" + "id=" + id + ", login=" + login + ", "
				+ "password=" + password
				+ ", email=" + email + ","
				+ "firstName=" + firstName
				+ ", lastName=" + lastName + ","
				+ "birthday=" + birthday
				+ ", role=" + role + '}';
	}
}
